-
Notifications
You must be signed in to change notification settings - Fork 75
Format header #1459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Format header #1459
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the API, it's really useful! I do have some comments
* A lambda used to format a column header (its displayed name) when rendering a dataframe to HTML. | ||
* | ||
* The lambda runs in the context of [FormattingDsl] and receives the [ColumnWithPath] of the header to format. | ||
* Return a [CellAttributes] (or `null`) describing CSS you want to apply to the header cell. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*the CSS
* Return a [CellAttributes] (or `null`) describing CSS you want to apply to the header cell. | ||
* | ||
* Examples: | ||
* - Center a header: `attr("text-align", "center")` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*the header
* Examples: | ||
* - Center a header: `attr("text-align", "center")` | ||
* - Make it bold: `bold` | ||
* - Set custom color: `textColor(rgb(10, 10, 10))` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*a custom color
// region DataFrame.formatHeader | ||
|
||
/** | ||
* **Experimental API. It may be changed in the future.** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to introduce an Experimental OptIn for this API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe kdoc note is enough.
*/ | ||
@Suppress("UNCHECKED_CAST") | ||
public fun <T, C> HeaderFormatClause<T, C>.with(formatter: HeaderColFormatter<C>): FormattedFrame<T> { | ||
val selectedPaths = df.getColumnPaths(UnresolvedColumnsPolicy.Skip, columns).toSet() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe move this to formatHeaderImpl
val composedHeader: HeaderColFormatter<Any?> = { col -> | ||
val path = col.path | ||
// Merge attributes from selected parents | ||
val parentAttributes = if (path.size > 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait... so you're merging attributes from parents here, but also in html.kt? how does it work?
if (hf == null) { | ||
null | ||
} else { | ||
// collect attributes from parents |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you also do this in formatHeader.kt?
var nestedRowsLimit: Int? = 5, | ||
var cellContentLimit: Int = 40, | ||
var cellFormatter: RowColFormatter<*, *>? = null, | ||
var headerFormatter: HeaderColFormatter<*>? = null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a public data class; you're breaking binary compatibility by adding this, especially halfway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had the same issue with ParserOptions
:/ unfortunately, using data classes in the public api is a bit of a nightmare. Adding a new argument breaks the constructor, componentX()
, and copy()
function.
Check out ParserOptions
for a workaround for this
No description provided.